<%@page import="com.bill.common.utils.TranType"%>
<%@page import="com.bill.common.system.dto.SingleGroupReportStatDTO"%>
<%@page import="java.util.List"%>
<%@page import="com.sinba.common.dto.PageDTO"%>
<%@page import="com.bill.common.system.dto.TransactionRecordDTO"%>
<%@page import="com.bill.common.system.service.ITransactionRecordService"%>
<%@page import="com.bill.common.user.dto.AccountDTO"%>
<%@page import="com.bill.common.user.service.IAccountService"%>
<%@page import="org.springframework.web.context.support.WebApplicationContextUtils"%>
<%@page import="org.springframework.context.ApplicationContext"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> 
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ include file="../language.jsp" %>
<%
if(session.getAttribute("password2")==null){
	response.sendRedirect( "login2.jsp?pageUrl=user/st2aticDetails.jsp");
	return;
}

ApplicationContext ac = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
ITransactionRecordService transactionRecordService = (ITransactionRecordService)ac.getBean("transactionRecordService");
TransactionRecordDTO trDTO = new TransactionRecordDTO();
trDTO.setLoginName((String)session.getAttribute("loginName"));
int pages = 1;
String sidx = "recordId";
String sord="desc";

Object param1 = request.getParameter("trDTO.transactionType");
if(param1!=null 
&& param1!="" 
&& !"null".equals(param1)){
	trDTO.setTransactionType(request.getParameter("trDTO.transactionType"));
	pages=1;
}
if(request.getParameter("pages")!=null && request.getParameter("_pages")!=""){
	pages = Integer.parseInt(request.getParameter("pages"));
}
int rows = 10;
int start = ( pages - 1 ) * rows;
trDTO.setStart( start );
trDTO.setLimit( rows );
trDTO.setTransactionTypes(new String[]{TranType.RiFenHong});
trDTO.setSearchType("Static");

PageDTO pageDTO = transactionRecordService.findTransactionRecordPager(trDTO, sord, sidx);
if(pageDTO!=null){
	pageDTO.setPage( pages );
	pageDTO.setRows( rows );
}
request.setAttribute("pageDTO",pageDTO);

//统计：
Double income = 0D;
TransactionRecordDTO trDto1 = new TransactionRecordDTO();
trDto1.setInOrExp("income");
trDto1.setTransactionTypes(new String[]{TranType.RiFenHong});
trDto1.setLoginName((String)session.getAttribute("loginName"));
List<SingleGroupReportStatDTO> sgrs = transactionRecordService.statAccount(trDto1);
for(SingleGroupReportStatDTO sgr : sgrs){
	if(sgr.getAggField()!=null){
		income = income+sgr.getAggField();
	}
}
request.setAttribute("income",income);

%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<meta name="apple-mobile-web-app-capable" content="yes" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=device-width, initial-scale=1" >
<title><fmt:message key="i18n.jtMoneyDetail"/>-<fmt:message key="i18n.title"/></title>
<link rel="shortcut icon" href="../index/favicon.png" />
<link href="../skin/skin1/css/subPage.css" rel="stylesheet">
<link rel="stylesheet" href="css/sub_page_main_style.css" />
</head>
<body style="background:#fff;height:800px;">
<div class="account">
	<div class="top"><fmt:message key="i18n.moneyManage"/> &gt; <fmt:message key="i18n.staticDetail"/></div>
	<!-- <div class="left"></div> -->
	
    <div class="right" style="margin: 0px;">
    	<h4><fmt:message key="i18n.totalincome"/>:<fmt:formatNumber value="${income}" pattern="#0.0000"/> </h4>
    	<table width="100%" border="0" cellspacing="0" cellpadding="0">
	        <tr>
	          <th scope="col" class="cxtj">
		    	<form id="bonusSeachForm" action="dynamicAward.jsp" method="post">
		    	<%-- <form id="bonusSeachForm" action="st2aticDetails.jsp" method="post"> --%>
				<input name="sidx" value="recordId" type="hidden" >
				<input name="sord" value="desc" type="hidden" >
				<input name="trDTO.searchType" value="bonus" type="hidden" >
				<input name="trDTO.loginName" value="${session.loginName }" type="hidden" >
				<label><fmt:message key="i18n.jiesuanData"/>:</label><input name="trDTO.startTime" placeholder="请输入开始时间" class="srk"></input>
				<fmt:message key="i18n.to"/><input name="trDTO.endTime" placeholder="请输入结束时间" class="srk"/> 
				<a style="cursor: pointer;" id="doSeach"><input type="button" value="<fmt:message key="i18n.serach"/>" class="cx_an"/></a>
				</form>
	          </th>
	        </tr>
	    </table>
    	<h4><fmt:message key="title.historyRecord"/></h4>
	    <table width="100%" border="0" cellspacing="0" cellpadding="0" id="smpl_tbl">
	    	<thead>
       			<tr class="color1">
       				<th><fmt:message key="i18n.type"/></th>
       				<th><fmt:message key="i18n.jiaoyiUser"/></th>
       				<th><fmt:message key="i18n.income"/></th>
       				<%--  <th><fmt:message key="i18n.transferredBonus"/></th>
       				
       				<th><fmt:message key="i18n.zhichu"/></th>
       				<th><fmt:message key="i18n.balance"/></th>--%>
       				<th><fmt:message key="i18n.operationTime"/></th>
       				<th><fmt:message key="i18n.remark"/></th>
       			</tr>
       		</thead>
       		<tbody>
       			<c:forEach items="${pageDTO.data}" var="data">
       				<tr>
       					<td><fmt:message key="${data.transactionType}" /></td>
       					<td>${data.transactionObject}</td>
       					<td><fmt:formatNumber value="${data.income}" pattern="#0.0000"/></td>
       					<%--  <td><fmt:formatNumber value="${data.bugOutSumOfMoney}" pattern="#0.0000"/></td>
       					
       					<td>${data.expenditure}</td>
       					<td><fmt:formatNumber value="${data.balance}" pattern="#0.0000"/></td>--%>
       					<td><fmt:formatDate value="${data.optDate}" pattern="yyyy-MM-dd HH:mm:ss"/></td>
       					<td>${data.remark}</td>
       				</tr>
       			</c:forEach>
       			<c:if test="${empty pageDTO.data}">
       				<tr>
       					<td colspan="7" align="center"><fmt:message key="i18n.noData"/>!</td>
       				</tr>
       			</c:if>
       		</tbody>
	    </table>
	    <!-- 分页 start -->
		<div class="page">
		<div id="tr_recommendGrid_pager" class="page_r">
			<ul>
				<li><a href="st2aticDetails.jsp?pages=1&trDTO.transactionType=<%=request.getParameter("trDTO.transactionType") %>"><fmt:message key="i18n.firstPage"/></a></li>
				<c:if test="${pageDTO.page!=1}">
					<li><a href="st2aticDetails.jsp?pages=${pageDTO.page-1}&trDTO.transactionType=<%=request.getParameter("trDTO.transactionType") %>"><fmt:message key="i18n.upPage"/></a></li>
				</c:if>
				<li><a>${pageDTO.page}/${pageDTO.total}</a></li>
				<c:if test="${pageDTO.page+1<=pageDTO.total}">
					<li><a href="st2aticDetails.jsp?pages=${pageDTO.page+1}&trDTO.transactionType=<%=request.getParameter("trDTO.transactionType") %>"><fmt:message key="i18n.nextPage"/></a></li>
				</c:if>
				<li><a href="st2aticDetails.jsp?pages=${pageDTO.total}&trDTO.transactionType=<%=request.getParameter("trDTO.transactionType") %>"><fmt:message key="i18n.endPage"/></a></li>
				<li><a><fmt:message key="i18n.total"/>${pageDTO.totalSize}<fmt:message key="i18n.tiao"/></a></li>
			</ul>
		</div>
		</div>
		<!-- 分页 end  -->
	</div>
</div>
<script type="text/javascript" src="../scripts/jquery/jquery-1.4.2.min.js"></script>
<script>

$(function(){
	//showTransRecord('tr_recommend_table','tr_recommend_pager','recommend',1,10,'optDate','desc');
	//showDirectPushUser('tr_recommendGrid_table','tr_recommendGrid_pager','${user.loginName}',1,10,'registerTime','desc');
    $("#doSeach").click(function(){
    	$("#bonusSeachForm").submit();
    });
})

</script>

</body>
</html>